//
//  YPKStatisticsRequest.m
//  Yopark
//
//  Created by 王家骏 on 14/10/30.
//  Copyright (c) 2014年 developer. All rights reserved.
//

#import "YPKStatisticsRequest.h"
#import "YPKHttpClient.h"
#import "AFHTTPRequestOperationManager.h"

@implementation YPKStatisticsRequest

+ (void)getHotCityListSuccess:(void (^)(id))success
                      failure:(void (^)(NSError *))failure
{
    [self getURLString:kGetCityList
            parameters:@{@"app_type":@(3)}
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}

+ (void)getLandMarkListWithCityId:(NSString *)cityId
                          success:(void (^)(id))success
                          failure:(void (^)(NSError *))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"city_id":cityId,
                            @"is_hot":@(1)};
    [self getURLString:kGetLandMarkList
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}

+ (void)getCommunityListWithDistrictId:(NSString *)districtId
                               success:(void (^)(id))success
                               failure:(void (^)(NSError *))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"district_id":districtId};
    [self getURLString:kGetCommunityList
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}

+ (NSURLSessionDataTask *)getHouseListWithCityId:(NSString *)cityId
                    districtId:(NSString *)districtId
                    landmarkId:(NSString *)landmarkId
                   communityId:(NSString *)communityId
                     houseType:(NSString *)houseType
                         price:(NSString *)price
                  personNumber:(NSString *)personNumber
                          mark:(NSString *)mark
                 houseListSort:(YPKHouseListSort)houseListSort
                     leaseType:(YPKLeaseType)leaseType
                   startNumber:(NSString *)startNumber
                     endNumber:(NSString *)endNumber
                       success:(void (^)(id))success
                       failure:(void (^)(NSError *))failure
{
    NSString *sort;
    switch (houseListSort) {
        case YPKHouseListSortDefault:
            sort = @"";
            break;
        case YPKHouseListSortPriceUp:
            sort = @"jga";
            break;
        case YPKHouseListSortPriceDown:
            sort = @"jgd";
            break;
        case YPKHouseListSortSquareDown:
            sort = @"mjd";
            break;
        case YPKHouseListSortSquareUp:
            sort = @"mja";
            break;
        default:
            break;
    }
    NSDictionary *parms = @{@"app_type":@3,
                            @"city_id":cityId,
                            @"district_id":districtId,
                            @"landmark_id":landmarkId,
                            @"community_id":communityId,
                            @"house_type":houseType,
                            @"sort":sort,
                            @"price":price,
                            @"person_number":personNumber,
                            @"mark":mark,
                            @"lease_type":@(leaseType),
                            @"start_no":startNumber,
                            @"end_no":endNumber};
    return [self getURLString:kGetHouseList
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}
+ (void)getHotHouseListWithLeaseType:(YPKLeaseType)leaseType
                         startNumber:(NSString *)startNumber
                           endNumber:(NSString *)endNumber
                             success:(void (^)(id responseObject))success
                             failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"lease_type":@(leaseType),
                            @"start_no":startNumber,
                            @"end_no":endNumber};
    [self getURLString:kGetHotHouseList
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}
+ (void)getLandMarkHouseCountWithCityId:(NSString *)cityId
                               success:(void (^)(id responseObject))success
                               failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"city_id":cityId,
                            @"is_hot":@(1)};
    [self getURLString:kGetLandMarkHouseCount
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}
+ (void)getAppStoreVersionWithAppId:(NSString *)appId
                             sucess:(void (^)(id responseObject))success
                            failure:(void (^)(NSError *error))failure
{
    NSDictionary *parameters = @{@"id":appId};
    [self getURLString:kAppStore
            parameters:parameters
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}
+ (void)getMapLandMarkHouseCountWithCityId:(NSString *)cityId
                                   success:(void (^)(id responseObject))success
                                   failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"city_id":cityId};
    [self getURLString:kGetLandMarkHouseCount
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];

}
+ (void)getNearHouseListWithHouseId:(NSString *)houseId
                          leaseType:(YPKLeaseType)leaseType
                      houseListSort:(YPKHouseListSort)houseListSort
                        startNumber:(NSString *)startNumber
                          endNumber:(NSString *)endNumber
                            success:(void (^)(id))success
                            failure:(void (^)(NSError *))failure
{
    NSString *sort;
    switch (houseListSort) {
        case YPKHouseListSortDefault:
            sort = @"";
            break;
        case YPKHouseListSortPriceUp:
            sort = @"jga";
            break;
        case YPKHouseListSortPriceDown:
            sort = @"jgd";
            break;
        case YPKHouseListSortSquareDown:
            sort = @"mjd";
            break;
        case YPKHouseListSortSquareUp:
            sort = @"mja";
            break;
        default:
            break;
    }
    
    NSDictionary *parms = @{@"app_type":@(3),
                            @"house_id":houseId,
                            @"lease_type":@(leaseType),
                            @"sort":sort,
                            @"start_no":startNumber,
                            @"end_no":endNumber};
    [self getURLString:kGetNearHouseList
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}

+ (void)getHouseDetailWithHouseId:(NSString *)houseId
                          success:(void (^)(id))success
                          failure:(void (^)(NSError *))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"house_id":houseId};
    [self getURLString:kGetHouseDetail
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}

+ (void)getHouseServiceListWithHouseId:(NSString *)houseId
                               success:(void (^)(id))success
                               failure:(void (^)(NSError *))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"house_id":houseId};
    [self getURLString:kGetHouseServiceList
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}

+ (void)getHouseCommentListWithHouseId:(NSString *)houseId
                           startNumber:(NSString *)startNumber
                             endNumber:(NSString *)endNumber
                               success:(void (^)(id))success
                               failure:(void (^)(NSError *))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"house_id":houseId,
                            @"start_no":startNumber,
                            @"end_no":endNumber};
    [self getURLString:kGetHouseCommentList
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}

+ (void)getHouseImgListWithHouseId:(NSString *)houseId
                           success:(void (^)(id))success
                           failure:(void (^)(NSError *))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"house_id":houseId};
    [self getURLString:kGetHouseImgList
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}

+ (void)getImgTypeListSuccess:(void (^)(id responseObject))success
                      failure:(void (^)(NSError *error))failure
{
    [self getURLString:kGetImgTypeList
            parameters:@{@"app_type":@(3)}
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}

+ (void)getCommunityDetailWithCommunityId:(NSString *)communityId
                                  success:(void (^)(id responseObject))success
                                  failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"community_id":communityId};
    [self getURLString:kGetCommunityDetail
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}
+ (void)getOrderListWithUserId:(NSString *)userId
                   startNumber:(NSString *)startNumber
                     endNumber:(NSString *)endNumber
                       success:(void (^)(id responseObject))success
                       failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"user_id":userId,
                            @"start_no":startNumber,
                            @"end_no":endNumber};
    [self getURLString:kGetOrderList
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}
+ (void)getAppointMentListWithUserId:(NSString *)userId
                         startNumber:(NSString *)startNumber
                           endNumber:(NSString *)endNumber
                             success:(void (^)(id responseObject))success
                             failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"user_id":userId,
                            @"start_no":startNumber,
                            @"end_no":endNumber};
    [self getURLString:kGetMyAppointMentList
            parameters:parms
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}
+ (void)getOrderStateListsuccess:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure
{
    [self getURLString:kGetOrderStateList
            parameters:@{@"app_type":@(3)}
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}
+ (void)postAppointmentWithHouseId:(NSString *)houseId
                          rentType:(int)rentType
                          userName:(NSString *)userName
                         userPhone:(NSString *)userPhone
                              date:(NSString *)date
                             token:(NSString *)token
                           success:(void (^)(id responseObject))success
                           failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"house_id":houseId,
                            @"rent_type":@(rentType),
                            @"user_name":userName,
                            @"user_phone":userPhone,
                            @"appoint_date":date,
                            @"token":token};
    [self postURLString:kAppointment
             parameters:parms
                success:^(id responseObject) {
                    success(responseObject);
                }
                failure:^(NSError *error) {
                    failure(error);
                }];
}
+ (void)houseBookingWithUserId:(NSString *)userId
                       houseId:(NSString *)houseId
                       checkin:(NSString *)checkin
                      checkout:(NSString *)checkout
                   contactName:(NSString *)contactName
                  contactPhone:(NSString *)contactPhone
                  contactEmail:(NSString *)contactEmail
                      guestNum:(NSString *)guestNum
                         token:(NSString *)token
                       success:(void (^)(id responseObject))success
                       failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"user_id":userId,
                            @"house_id":houseId,
                            @"checkin":checkin,
                            @"checkout":checkout,
                            @"contact_name":contactName,
                            @"contact_phone":contactPhone,
                            @"contact_email":contactEmail,
                            @"guest_num":guestNum,
                            @"token":token};
    [self postURLString:kHouseBooking
             parameters:parms
                success:^(id responseObject) {
                    success(responseObject);
                }
                failure:^(NSError *error) {
                    failure(error);
                }];
}
+ (void)sendCodeWithPhoneNum:(NSString *)phoneNum
                  actionType:(YPKUserActionType)actionType
                     success:(void (^)(id responseObject))success
                     failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"phone":phoneNum,
                            @"action_type":@(actionType)};
    [self postURLString:kSendCode
             parameters:parms
                success:^(id responseObject) {
                    success(responseObject);
                }
                failure:^(NSError *error) {
                    failure(error);
                }];
}
+ (void)registerWithPhoneNum:(NSString *)phoneNum
             verficationCode:(NSString *)verficationCode
                       email:(NSString *)email
                    password:(NSString *)password
                     success:(void (^)(id responseObject))success
                     failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"phone":phoneNum,
                            @"verfication_code":verficationCode,
                            @"email":email,
                            @"password":password};
    [self postURLString:kRegister
             parameters:parms
                success:^(id responseObject) {
                    success(responseObject);
                }
                failure:^(NSError *error) {
                    failure(error);
                }];
}

+ (void)loginWithusername:(NSString *)username
          verficationCode:(NSString *)verficationCode
                 password:(NSString *)password
                 deviceId:(NSString *)deviceId
               deviceType:(NSString *)deviceType
                   osType:(NSString *)osType
                osVersion:(NSString *)osVersion
                  success:(void (^)(id responseObject))success
                  failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"username":username,
                            @"verfication_code":verficationCode,
                            @"app_type":@3,
                            @"password":password,
                            @"device_id":deviceId,
                            @"device_type":deviceType,
                            @"os_type":osType,
                            @"os_version":osVersion};
    [self postURLString:kLogin
             parameters:parms
                success:^(id responseObject) {
                    success(responseObject);
                }
                failure:^(NSError *error) {
                    failure(error);
                }];
}
+ (void)modifyPasswordWithUserId:(NSString *)userId
                     oldPassword:(NSString *)oldPassword
                     newPassword:(NSString *)newPassword
                         success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"user_id":userId,
                            @"old_password":oldPassword,
                            @"new_password":newPassword};
    [self postURLString:kModifyPassword
             parameters:parms
                success:^(id responseObject) {
                    success(responseObject);
                }
                failure:^(NSError *error) {
                    failure(error);
                }];
}
+ (void)modifyPersonalWithUserId:(NSString *)userId
                        fullName:(NSString *)fullName
                        phoneNum:(NSString *)phoneNum
                           email:(NSString *)email
                         success:(void (^)(id responseObject))success
                         failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"user_id":userId,
                            @"fullname":fullName,
                            @"phone":phoneNum,
                            @"email":email};
    [self postURLString:kModifyPersonal
             parameters:parms
                success:^(id responseObject) {
                    success(responseObject);
                }
                failure:^(NSError *error) {
                    failure(error);
                }];
}
+ (void)logoutWithUserId:(NSString *)userId
                 success:(void (^)(id responseObject))success
                 failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"user_id":userId};
    [self postURLString:kLogout
             parameters:parms
                success:^(id responseObject) {
                    success(responseObject);
                }
                failure:^(NSError *error) {
                    failure(error);
                }];
}

+ (void)resetPasswordWithPhoneNum:(NSString *)phoneNum
                         password:(NSString *)password
                            email:(NSString *)email
                  verficationCode:(NSString *)verficationCode
                          success:(void (^)(id responseObject))success
                          failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"password":password,
                            @"email":email,
                            @"phone":phoneNum,
                            @"verfication_code":verficationCode};
    [self postURLString:kResetPassword
             parameters:parms
                success:^(id responseObject) {
                    success(responseObject);
                }
                failure:^(NSError *error) {
                    failure(error);
                }];
}
+ (void)setHeadImageWithUserId:(NSString *)userId
                     imageData:(NSData *)imageData
                       success:(void (^)(id responseObject))success
                       failure:(void (^)(NSError *error))failure
{
    NSDictionary *parms = @{@"app_type":@(3),
                            @"user_id":userId,
                            @"img_data":imageData};
    [self postURLString:kSetHeadImage
             parameters:parms
                success:^(id responseObject) {
                    success(responseObject);
                }
                failure:^(NSError *error) {
                    failure(error);
                }];
}
+ (void)getCouponListWithUserId:(NSString *)userId
                    startNumber:(NSString *)startNumber
                      endNumber:(NSString *)endNumber
                        success:(void (^)(id responseObject))success
                        failure:(void (^)(NSError *error))failure
{
    NSDictionary *params = @{@"app_type":@(3),
                             @"user_id":userId,
                             @"start_no":startNumber,
                             @"end_no":endNumber};
    [self getURLString:kGetCouponList
            parameters:params
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}
+ (void)getCouponUsedListWithUserId:(NSString *)userId
                         startNumber:(NSString *)startNumber
                           endNumber:(NSString *)endNumber
                             success:(void (^)(id responseObject))success
                             failure:(void (^)(NSError *error))failure
{
    NSDictionary *params = @{@"app_type":@(3),
                             @"user_id":userId,
                             @"start_no":startNumber,
                             @"end_no":endNumber};
    [self getURLString:kGetCouponUsedList
            parameters:params
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}
+ (void)getPersonalWithUserId:(NSString *)userId
                    withToken:(NSString *)token
                      success:(void (^)(id responseObject))success
                      failure:(void (^)(NSError *error))failure
{
    NSDictionary *params = @{@"app_type":@(3),
                             @"user_id":userId,
                             @"token":token};
    [self getURLString:kGetPersonal
            parameters:params
               success:^(id responseObject) {
                   success(responseObject);
               }
               failure:^(NSError *error) {
                   failure(error);
               }];
}

+ (void)getCommunityLocationDetailListWithEstateId:(NSString *)estateId
                                         leaseType:(NSString *)leaseType
                                           success:(void (^)(id responseObject))success
                                           failure:(void (^)(NSError *error))failure
{
    NSDictionary *params = @{@"app_type":@(3),
                             @"estate_id":estateId,
                             @"lease_type":leaseType};
    [self getURLString:kGetCommunityLocationDetailList parameters:params success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
    
}

+ (void)getAllCommunityLocationListSuccess:(void (^)(id responseObject))success
                                   failure:(void (^)(NSError *error))failure
{
    NSDictionary *params = @{@"app_type":@(3)};
    [self getURLString:kGetAllCommunityLocationList parameters:params success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
   
}

+ (void)uploadPhotoWithImageInfoDic:(NSMutableDictionary *)dic
                              image:(UIImage *)image
                            Success:(void (^)(id responseObject))success
                            failure:(void (^)(NSError *error))failure
{
    NSString *json;
    if ([NSJSONSerialization isValidJSONObject:dic]) {
        NSError *error;
        NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:&error];
        json =[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    }
    NSDictionary *params = @{@"app_type":@(3),
                             @"lease":json};
    [self postURLString:@"http://58.135.83.226:8088/index.php/v1/lease/leaseinsert" parameters:params success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

+ (void)getLeaseListWithUserId:(NSString *)userId
                       startNo:(NSString *)startNo
                         endNo:(NSString *)endNo
                       success:(void (^)(id responseObject))success
                       failure:(void (^)(NSError *error))failure {
    NSDictionary *params = @{@"user_id":userId,@"start_no":startNo,@"end_no":endNo,@"app_type":@"3"};
    [self getURLString:kGetLeaseList parameters:params success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];

}

+ (void)getYoparkLeaseListWithUserId:(NSString *)userId
                             startNo:(NSString *)startNo
                               endNo:(NSString *)endNo
                             success:(void (^)(id responseObject))success
                             failure:(void (^)(NSError *error))failure {
    NSDictionary *params = @{@"user_id":userId,@"start_no":startNo,@"end_no":endNo,@"app_type":@"3"};
    [self getURLString:kGetYoparkLeaseList parameters:params success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];

}

+ (void)getThirdLeaseListDetailWithOrderId:(NSString *)orderId
                                   success:(void (^)(id responseObject))success
                                   failure:(void (^)(NSError *error))failure {
    NSDictionary *params = @{@"order_id":orderId,@"app_type":@"3"};
    [self getURLString:kGetThirdLeaseListDetail parameters:params success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

+ (void)getYoparkLeaseListDetailWithOrderId:(NSString *)orderId
                                    success:(void (^)(id responseObject))success
                                    failure:(void (^)(NSError *error))failure {
    NSDictionary *params = @{@"order_id":orderId,@"app_type":@"3"};
    [self getURLString:kGetYoparkLeaseListDetail parameters:params success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

+ (void)getYoparkLeasePayOrderWithOrderId:(NSString *)orderId
                                  success:(void (^)(id responseObject))success
                                  failure:(void (^)(NSError *error))failure {
    NSDictionary *params = @{@"order_id":orderId,@"app_type":@"3"};
    [self getURLString:kGetLeaseYoparkPayOrder parameters:params success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

+ (void)getThirdLeasePayOrderWithOrderId:(NSString *)orderId
                                 success:(void (^)(id responseObject))success
                                 failure:(void (^)(NSError *error))failure {
    NSDictionary *params = @{@"order_id":orderId,@"app_type":@"3"};
    [self getURLString:kGetLeaseThirdPayOrder parameters:params success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

+ (void)getLeaseAssistPayOrderWithOrderNo:(NSString *)orderNo
                                    token:(NSString *)token
                                  success:(void (^)(id responseObject))success
                                  failure:(void (^)(NSError *error))failure {
    NSDictionary *params = @{@"order_no":orderNo,@"app_type":@"3",@"token":token};
    [self getURLString:kGetLeaseAssistPayOrder parameters:params success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

#pragma mark - private

+ (NSURLSessionDataTask *)getURLString:(NSString *)urlString
          parameters:(NSDictionary *)params
             success:(void (^)(id responseObject))success
             failure:(void (^)(NSError *error))failure{
    return [[YPKHttpClient shareClient] GET:urlString
                          parameters:params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
                                 NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
                                 id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
                                 
                                 success(json);
                             }
                             failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 failure(error);
                             }];
}
+ (void)postURLString:(NSString *)urlString
           parameters:(NSDictionary *)params
              success:(void (^)(id responseObject))success
              failure:(void (^)(NSError *error))failure{
    [[YPKHttpClient shareClient] POST:urlString
                          parameters:params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
                                 NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
                                 id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
                                 
                                 success(json);
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 failure(error);
                             }];
    
}

@end
